
# 位置参数
def greet(name,msg):
    print("Hello",name + ', ' + msg)

# 默认参数
def greet2(name,msg="你好"):
    print("Hello",name + ', ' + msg)


# 可变参数
def greet3(name,*args):
    print("Hello",name)
    for arg in args:
        print(arg)

# 关键字参数
def greet4(name,**kwargs):
    if kwargs is not None:
        print("Hello",name)
        for key,value in kwargs.items():
            print(key,value)

if __name__ == "__main__":
    # 调用位置参数
    greet('runoob','你好')
    # 调用关键字参数
    greet(msg='你好',name='runoob')
    greet(msg='你好',name='tom')
    # 调用默认参数
    greet2('runoob') # 使用默认的值
    greet2('runoob','你吃了吗？')  # 使用指定的值
    
    # 调用可变参数
    greet3('runoob','你好','你吃了吗？','我饿了')
    args = ('你好', '你吃了吗？', '我饿了')
    greet3('runoob', *args)

    # 调用关键字参数 keywords must be strings
    greet4('runoob', **{'1':'你好','2':'你吃了吗？','3':'我饿了'})
    kwargs = {'1':'你好','2':'你吃了吗？','3':'我饿了'}
    greet4('runoob', **kwargs)


  


